Boot Troubleshooting Labs
1. Selecting a Boot Target
Machines: server1
A system booted in to different targets
In this lab, you will configure your server1 system to boot in to different
targets.
From the
desktop1system reset yourserver1system.Configure your
server1system to boot in to themulti-usertarget by default.Do not reboot your
server1system right now, as it will make your graphical console unavailable.[root@server1 ~]# systemctl set-default multi-user.target rm '/etc/systemd/system/default.target' ln -s '/usr/lib/systemd/system/multi-user.target' '/etc/systemd/system/default.target'
Verify that
multi-useris now indeed the new default target.[root@server1 ~]# systemctl get-default multi-user.target
Alternatively:
[root@server1 ~]# ls -l /etc/systemd/system/default.target lrwxrwxrwx. 1 root root 41 Mar 10 08:00 /etc/systemd/systemd/default.target -> /usr/lib/systemd/system/multi-user.target
In our environment, the graphical console is not available (except via
VNC). If you want to set the default target back to the [root@server1 ~]# systemctl set-default graphical.target |
2. Resetting a Lost Root Password
Machines: server1
A recovered root password
In this lab, you will recover a lost root password. Assume that you do not know the root password
for server1 and it must be changed.
Log in to the GUI of your
desktop1system using the guacamole interface.Start Konsole and then run the
virt-managertool.In the virt-manager GUI, select the
vserverVM then click Open.The vserverVM is yourserver1.example.comhost.Click the Console button to see the VM’s console.
Click View → Scale Display → Always to make the entire console visible in the screen.
Reboot your system, and interrupt the countdown in the boot loader menu.
Click Send Key → Ctrl+Alt+Del.
When the boot loader menu appears, press any key to interrupt the countdown.
Edit the default boot loader entry (in memory) to abort the boot process just after all file systems have been mounted, but before control is handed over to
systemd, then boot.Use the cursor keys to highlight the default boot loader entry.
Press e to edit the current entry.
Using the cursor keys, navigate to the line that starts with
linux16.Press End to move the cursor to the end of the line.
Append
init=/bin/bashto the end of the line.You will need to open the virtual keyboard to do the next step. To open the virtual keyboard:
Mac: press Ctrl - Option - Shift
Linux: press Ctrl - Alt - Shift
From the virtual keyboard you can click Ctrl + x to boot using the modified configuration. Press the key combo again to close the virtual keyboard.
At the
bashprompt do the following:bash# /usr/sbin/load_policy -i bash# mount -o remount,rw /
Change the root password to something of your own choosing.
bash# passwd root
Run the
exec /sbin/initcommand to resume the initialization and finish the system boot.bash# exec /sbin/init
When the login prompt appears, log in to your
server1machine asrootusing the new root password.Reboot
server1before proceeding to the next lab.
3. Repairing Boot Problems
Machines: server1 bootvm
Your machine boots normally, without user intervention
In this lab, you will recover from an error in /etc/fstab.
Log in to the GUI of your
desktop1system using the guacamole interface.Start Konsole, then run the
virt-managertool.Create an entry in
/etc/fstabthat will simulate a failed boot situation, then reboot.[root@localhost ~]# echo "/dev/fail /fail xfs defaults 1 1" >> /etc/fstab [root@localhost ~]# reboot
Take a good look at the console of your
server1machine. It is stuck early in the boot process due to the badfstabentry.Reboot the machine and interrupt the boot loader menu countdown.
If you wait long enough, the system will eventually spawn a rescue shell by itself, but that can take a while, so we will spawn the rescue shell manually.
If you use Ctrl+Alt+Del to reboot and it does not cause the system to reboot, you can either wait for the task to time out or use the VM’s power switch to force a reboot. When the boot loader menu appears after the BIOS self-test, press any key to interrupt the countdown.
Use the cursor keys to highlight the default boot loader entry.
Press e to edit the current entry.
Using the cursor keys, navigate to the line that starts with
linux16.Press End to move the cursor to the end of the line.
Append
systemd.unit=emergency.targetto the end of the line.Press Ctrl+x to boot using the modified configuration.
Log in to the emergency mode.
Pay close attention to any errors you receive. Note that it did not hang for a long time waiting to show the password prompt. This is one of the benefits of booting in this mode.
At the
Give root password for maintenanceprompt enter the root password.
Inspect what file systems are currently mounted.
[root@localhost ~]# mount ... /dev/vda1 on / type xfs (ro,relatime,seclabel,attr2,inode64,noquota)
It appears that the root file system is mounted read-only; mount it read-write.
[root@localhost ~]# mount -oremount,rw /
Attempt to mount all the other file systems.
[root@localhost ~]# mount -a mount: mount point /fail does not exist
Open
/etc/fstabin an editor and fix the issue.[root@localhost ~]# vi /etc/fstab
Remove the invalid line (the one with
/fail).Save your changes, then exit your editor.
Verify that
/etc/fstabis now correct by attempting to mount all entries.[root@localhost ~]# mount -a
Exit your emergency shell and reboot the system by typing
reboot.[root@localhost ~]# reboot
Your system should now boot normally.
4. Repairing a Boot Loader Problem
Machines: server1
A machine that boots normally without user intervention
In this lab, you will repair an issue with the boot loader configuration on one of your machines.
Access the
server1system using the GUI and log in asroot.Break grub with the following command then reboot the VM.
[student@server1 ~]$ sed -i "s/linux16/os16/" /boot/grub2/grub.cfg [student@server1 ~]$ reboot
The system should fail to boot right after coming out of grub.
error: can't find command `os16'. unaligned pointer 0x3fed58bf Aborted. Press any key to exit.
Reboot the
server1VM by using Send Key → Ctrl+Alt+Del, then interrupt the boot loader countdown timer.Move the cursor to the default boot entry, then press e to edit that entry. Inspect the configuration closely, looking for text starting with
os16(inserted with thesedcommand earlier).Find the line that is blocking the boot process, modify it, and then boot with these changes.
os16is not a validgrubdirective. Change it tolinux16.Press Ctrl+x to boot your system with the modified configuration.
Wait for the system to boot, log in as
root, and then generate a newgrub2configuration.Do not immediately overwrite the existing configuration, but inspect the new configuration first.
[root@server1 ~]# grub2-mkconfig > /tmp/newgrub
Look at the differences between the broken existing grub and the new proposed configuration. (Ignore the lines about msdos.)
[root@server1 ~]# diff /boot/grub2/grub.cfg /tmp/newgrub
Commit the configuration to disk.
[root@server1 ~]# grub2-mkconfig > /boot/grub2/grub.cfg
Reboot your machine, and check if it boots normally again without user intervention.
[root@server1 ~]# systemctl reboot